package com.jtcl.enums;

/**
 * @author sjt
 * @since 2021-02-26 13:04
 */
public enum OrderState {
    /**
     *
     */
    UNFOUND(1, "待使用"),
    USING(2, "正使用"),
    COMPLETE(3, "已完成"),
    REFUND(4, "退款"),
    NOUSE(5, "放弃订单");

    private String desc;
    private int code;

    private OrderState(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public static OrderState getState(int code) {
        for (OrderState orderState : OrderState.values()) {
            if (orderState.ordinal() + 1 == code) {
                return orderState;
            }
        }
        return null;
    }
}
